package belf.migrate.api.table.schema;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/** 表的主键元数据 */
@Data
@AllArgsConstructor
public class PrimaryKey implements Serializable {
    private static final long serialVersionUID = 7L;

    // 该字段暂时没用。默认可以用“PRIMARY”
    private String primaryKey = "PRIMARY";
    /** 可以是单字段做主键，也可以是多个字段联合做主键 */
    private List<String> columnNames;

    public static PrimaryKey of(String primaryKey, List<String> columnNames) {
        return new PrimaryKey(primaryKey, columnNames);
    }

    public PrimaryKey copy() {
        return PrimaryKey.of(primaryKey, new ArrayList<>(columnNames));
    }
}
